Repository navigation
scripts: build-tools.sh: Use getopts, breakdown script to functions - #2657
Conversation
marc-hb
left a comment
There was a problem hiding this comment.
Minor comment, all the rest looks fine. However:
- you're changing the behavior slightly: now the user can't build the fuzzer first and the tests second.
- as this script is very short, you rewrote more than half of its lines.
So would you mind pushing the cleanup one step further and add a main() function and local DO_BUILD_TEST etc. variables? See rationale at #2606 (comment)
There was a problem hiding this comment.
At least a warning, preferably a fatal error.
I checked the earlier code and you are right, the order of options is infact affecting the execution of the script. Is that by design? However, do we really want our scripts to be options/arguments order sensitive? Seems pretty weird to me that the order of options matter and change the execution of script. This is just too subtle a information that will not be reflected to anyone who is just using the script following the help. Maybe it makes sense to first build fuzzer and then the tests. |
I suspect not but I don't know, I'm new here. I copied the author (based on This was just an example of you cleaning the script beyond merely switching to getopts. Might as well go all the way. |
Order shouldn't change execution, but there is one exception - if you pass the same argument 2nd time then it should be overwrittene. So |
82dd56d to
149e883
Compare
This would be the behavior in the current implementation. |
|
@marc-hb I have broken down the script into functions, using local variables(with few global variables) and using getopts for parsing arguments. Please review. |
marc-hb
left a comment
There was a problem hiding this comment.
Much better than the original, thanks! Minor issues below.
There was a problem hiding this comment.
Duplicate SCRIPT_DIR definition, you have another one in main().
You can make all these local variables in main() if you prefer.
There was a problem hiding this comment.
SCRIPT_DIR is accessed in all the three functions, that's why made it global. But yeah, missed the duplicate.
There was a problem hiding this comment.
local in main() is almost the same as global. One difference is when you comment out main() and source the script in your current shell for interactive testing.
-main "$@"
+# main "$@"
There was a problem hiding this comment.
Ah, that's good to know. Very different than block scoping you'd see elsewhere. Using local now.
149e883 to
1afd069
Compare
Breakdown script to functions, use local variables, and a main function. Use getopts to parse the arguments instead of manual parsing to leave no room for errors, bugs, and inconsistent conventions introduced by custom implementation. Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
1afd069 to
668d804
Compare
|
CI known issues. |
Use getopts to parse the arguments instead of manual parsing to leave no
room for errors, bugs, and inconsistent conventions introduced by custom
implementation.
Signed-off-by: Shreeya Patel shreeya.patel23498@gmail.com